package com.jt.aop;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import com.jt.vo.SysResult;

import ch.qos.logback.classic.Logger;
import lombok.extern.slf4j.Slf4j;

//@ControllerAdvice	+ @ResponseBody//定义为全局异常的处理机制
@RestControllerAdvice
@Slf4j
public class RuntimeAOP {
	
	//当前AOP拦截的异常类型
	@ExceptionHandler(RuntimeException.class)
	public SysResult runtime(Exception exception) {
		log.debug(exception.getMessage());
		exception.printStackTrace();	//输出异常信息
		return SysResult.fail();
	}
}
